Skip to content

gottaBoy/assembly-learning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

assembly on mac

-t -u -d -a

汇编语言例子

默认例子

data segment;定义数据段
  x db 'A'; define byte定义x为一个值为A的ASCII码的字节型变量
  y dw 30h; define word定义y为一个值为30h(48)的字型变量
  z dd 40h; define double word定义z为一个值为40h(64)的双字型变量
  a dw ?;定义一个变量
data ends;段结束的标记

stack1 segment para stack;不需要堆栈段可以不要这部分
  db 10h dup(0)
stack1 ends

code segment
assume cs:code,ds:data; assume伪指令用于确定段与段寄存器的关系,assume不会翻译成机器指令,但会存在于exe的文件头中,这会方便DOS重新分配内存时改变对应地址指针寄存器的值
start:mov ax,data;汇编后段名变成立即数,立即数不能直接赋值给段寄存器
  mov ds,ax;段寄存器将指向data数据段
  mov dl,x;显示字符前将字符移动到dl
  mov ah,02h;调用字符显示
  int 21h
  mov ah,4ch;4ch对应返回控制台子程序
  int 21h;根据ah确定子程序,自动跳转到子程序入口地址
 code ends
end start

大小写转换

data segment;数据段
  errs db 'error!$'
data ends

stack1 segment para stack;堆栈段
  
stack1 ends

code segment;代码段
assume cs:code,ds:data
start:mov ax,data;程序起点
      mov ds,ax
input:mov ah,08h;控制台输入到al
      int 21h
      cmp al,'0';是否=0
      jz zero
      cmp al,'A';是否>=A,大于等于则cf=0,对应jnc
      jc err;<A且!=0的情况
      ;下面的情况>=A
      cmp al,5bh;是否<=Z,和Z的后一个字符比较,小于则cf=1,对应jc
      jc plus
      ;下面的情况>Z
      cmp al,'a'
      jc err
      cmp al,7bh
      jc minus
      jnc err
zero: mov dl,'0';移动到dl供显示
      mov ah,02h;字符显示
      int 21h
      mov ah,4ch;返回控制台
      int 21h
plus: add al,20h
      mov dl,al
      jmp show
minus: sub al,20h
       mov dl,al
       jmp show
show: mov ah,02h;字符显示
      int 21h
      loop input
err:  mov dx,offset errs;将errs首地址传送给dx
      mov ah,09h;召唤字符串
      int 21h;芝麻开门
      loop input

code ends;代码段结束
 end start

mac下运行debug

其他链接

https://github.com/icebreaker/floppybird
https://github.com/Apress/modern-x86-assembly-language-programming-3e
https://github.com/meihao1203/Greedy_Snake
https://github.com/oded8bit/Assembly-Lib
https://github.com/FriendLey/assembly-language-learning
https://github.com/lichuang/x86-asm-book-source
https://github.com/LeechanX/My-Compiler-Designer
https://github.com/luice/BUAA-Compiler-Pascal-to-x86
https://github.com/wangjunstf/TCP-IP-Network-Note
https://github.com/blueSky1825821/8086assembly
https://www.yuque.com/wangmin-giwdv/lh8d33/bg04id?#%20%E3%80%8A8086%E3%80%8B
https://github.com/Evian-Zhang/learn-assembly-on-Apple-Silicon-Mac
https://github.com/Evian-Zhang/Assembly-on-macOS
https://gitee.com/chen-lifeng20040204/typing_asm
https://www.cnblogs.com/mysweetAngleBaby/p/17113118.html
https://github.com/cloudwego/volo
https://cloverkit.dev/2020/02/25/iTerm2-%E7%BB%88%E7%AB%AF%E7%BE%8E%E5%8C%96%E6%8C%87%E5%8C%97/
https://evian-zhang.github.io/articles/Assembly/macOS%E4%B8%8A%E7%9A%84%E6%B1%87%E7%BC%96%E5%85%A5%E9%97%A8%EF%BC%88%E4%BA%94%EF%BC%89%E2%80%94%E2%80%94%E7%AC%AC%E4%B8%80%E4%B8%AA%E6%B1%87%E7%BC%96%E7%A8%8B%E5%BA%8F.html
https://www.cnblogs.com/mysweetAngleBaby/p/17113118.html


https://fengmuzi2003.gitbook.io/csapp3e
https://github.com/0voice/k8s_awesome_document
https://www.cnblogs.com/gnivor/p/15608515.html
https://zhuanlan.zhihu.com/p/272135463
https://www.freedos.org/download/
https://github.com/tidb-incubator/tidb-in-action

About

assembly mac m4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published