王爽 汇编语言程序设计实验10,题三,数值转换。(Assembly experiment Convert HEX to Decimal and Show on screen )...

不用多说了,就直接代码吧

  1  assume  cs: codesg,  ds: data 
  2  data segment
  3       ; 00 is filler a
  4       ; 317ah is 12666 hex value
  5       ; 0000h is high bits. if the number is big and hex value is f317ah, then here 0000h will be 0000fh
  6       ; 000Ah is hex value of 10.
  7       ; rest of 0008h are just filler to make the debug view eaiser
  8      dw  00 ,317ah,0000h,000Ah,0008h,0008h,0008h,0008h 
  9      
 10       ; here will hold decimal text
 11      db  '                  '
 12  data ends 
 13  codesg segment
 14  start:    
 15       mov  ax, data  ; set data address
 16       mov  ds, ax 
 17       mov  bx,  16     ; set decial text text offset in bx, because declare 8 words, so here is 16
 18       mov  cx,  0
 19       push  cx       ; push a zero in bottom of stack, and it will be terminator of text
 20       divNext:  
 21           CALL  DivDW       ;  return remainder in [0] position, and quotient is still in [2] for next divide
 22           mov  cx,  ds: [ 0 ]   ;  set remainder in cx
 23           add  cx, 30h      ;  add decimal ascii
 24           push  cx          ;  save the decimal in stack
 25          
 26           mov  ax,  ds: [ 2 ]   ;  using bit OR to merge Divident H to Divident Low
 27           OR  ax,  ds: [ 4 ]     ;  Divident H is ds:[4], Divident L is ds:[2]
 28           MOV  cx, ax         ;  Then check whether ds:[2] is 0 or not
 29           jcxz  EXIT_DN     ;  if quotient is 0, exit divNext
 30          
 31       jmp  divNext          ;  continue get next decimal value
 32      
 33       EXIT_DN:              ;  When run to here, the stack contain all decimal ascii  
 34           pop  cx             ;  get decimal ascii from stack
 35           jcxz  Exit_DT     ;  if ascii value in stack is 0, then exit. 
 36                           ;  This zero is the terminator pushed at line 19 
 37           mov   ds: [bx+ 16 ], cx   ; move the ascii to data section declared at line 11
 38           add  bx, 1
 39       jmp  EXIT_DN
 40      
 41       Exit_DT:
 42       Call   Show_Str       ;  Show_Str show text from memory declared at line 11
 43       
 44       mov  ax, 4c00h
 45       int  21h
 46      
 47       ; ********************************************************************
 48       ;                         CONVERT to DECIMAL    
 49       ; divisor 除数 
 50       ; divisor 除数 can 8 bits or 16 bits and can be in register or memory
 51       ; dividend 被除数 , have to be AX or DX and AX, 
 52       ; divisor is 8 bits, then dividend is in AX.              | the result is AL = quotient 商, AH = remainder 余 
 53       ; divisor is 16 bits, then dividend is in DX(H) and AX(L) | the result is AX = quotient 商, DX = remainder 余  
 54      
 55       divDW:    ; chapter: 8.7  Page 157 
 56       pop  BP    
 57       push  bx     
 58           MOV  BX,  ds: [ 2 ; 4240 Divident(L)             
 59           MOV  AX , ds: [ 4 ;  000f   Divident(H)
 60           MOV  CX , ds: [ 6 ;  000A     Divisor
 61           MOV  DX,  0         
 62           DIV  CX      ;  (DX(0) + AX(000f)) / CX
 63           mov   ds: [ 4 ], ax
 64           MOV  AX, BX  ;  move Divident (L) in AX
 65           DIV  CX      ;  (DX(0005) + AX (4240)) / CX
 66           mov   ds: [ 2 ], ax 
 67           mov   ds: [ 0 ], dx
 68       pop  bx
 69       PUSH  BP     ;  SET IP back to stack 
 70       ret
 71      
 72       ; ***********************************************************
 73       ; ******                   Show Text
 74       show_str:
 75       pop  bp 
 76           mov  ax, 0b86eh
 77           mov  ss, ax       ; row
 78           mov  si,  40        ; Column
 79           mov  bx,  0         ; String stard postion
 80           mov  ah,  00000010B   ; Font 
 81           push  ss
 82           push  si
 83           push  ds
 84           push  bx 
 85       main:              
 86           mov  cl,  ds: [bx+ 16 ]    ;  ds:[bx] is the character 
 87           mov  al, cl  
 88           mov  ch,  0
 89           jcxz  EXIT_SS
 90           mov   ss: [si], ax  ;  this  ss:[si+bx] is character position    
 91           inc  bx 
 92           add  si,  2
 93       jmp  short main
 94      
 95       EXIT_SS:         
 96           pop  bx            
 97           pop  ds            
 98           pop  si
 99           pop  ss
100       push  bp
101       ret  
102 codesg ends

 

转载于:https://www.cnblogs.com/yangbin990/archive/2011/09/17/2179889.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
4S店客户管理小程序-毕业设计,基于微信小程序+SSM+MySql开发,源码+数据库+论文答辩+毕业论文+视频演示 社会的发展和科学技术的进步,互联网技术越来越受欢迎。手机也逐渐受到广大人民群众的喜爱,也逐渐进入了每个用户的使用。手机具有便利性,速度快,效率高,成本低等优点。 因此,构建符合自己要求的操作系统是非常有意义的。 本文从管理员、用户的功能要求出发,4S店客户管理系统中的功能模块主要是实现管理员服务端;首页、个人中心、用户管理、门店管理、车展管理、汽车品牌管理、新闻头条管理、预约试驾管理、我的收藏管理、系统管理,用户客户端:首页、车展、新闻头条、我的。门店客户端:首页、车展、新闻头条、我的经过认真细致的研究,精心准备和规划,最后测试成功,系统可以正常使用。分析功能调整与4S店客户管理系统实现的实际需求相结合,讨论了微信开发者技术与后台结合java语言和MySQL数据库开发4S店客户管理系统的使用。 关键字:4S店客户管理系统小程序 微信开发者 Java技术 MySQL数据库 软件的功能: 1、开发实现4S店客户管理系统的整个系统程序; 2、管理员服务端;首页、个人中心、用户管理、门店管理、车展管理、汽车品牌管理、新闻头条管理、预约试驾管理、我的收藏管理、系统管理等。 3、用户客户端:首页、车展、新闻头条、我的 4、门店客户端:首页、车展、新闻头条、我的等相应操作; 5、基础数据管理:实现系统基本信息的添加、修改及删除等操作,并且根据需求进行交流信息的查看及回复相应操作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值